﻿using System;
using System.Diagnostics;
using System.IO;

namespace TextKeep;

public static  class FileUtility
{
    public static void DeleteFolder(string folderPath)
    {
        if (Directory.Exists(folderPath))
        {
            Directory.Delete(folderPath, true);
            Console.WriteLine("文件夹删除成功。");
        }
        else
        {
            Console.WriteLine("文件夹不存在。");
        }
    }

    public static void DeleteFile(string filePath)
    {
        if (File.Exists(filePath))
        {
            File.Delete(filePath);
            Console.WriteLine("文件删除成功。");
        }
        else
        {
            Console.WriteLine("文件不存在。");
        }
    }
    
    public static void OpenFolderInExplorer(string folderPath)
    {
        if (Directory.Exists(folderPath))
        {
            Process.Start("explorer.exe", folderPath);
        }
        else
        {
            Console.WriteLine("文件夹不存在。");
        }
    }

    public static void OpenFileInExplorer(string filePath)
    {
        if (File.Exists(filePath))
        {
            Process.Start("explorer.exe", $"/select,\"{filePath}\"");
        }
        else
        {
            Console.WriteLine("文件不存在。");
        }
    }
}